//
//  DDDeleteFileACK.m
//  MyClouds
//
//  Created by sarah doo on 13-8-11.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//

#import "DDDeleteFileACK.h"

@implementation DDDeleteFileACK

- (id)initWithData:(NSData *)data {
    self = [self initWithData:data];
    return self;
}

- (id)initWithResult:(int)result {
    self = [self init];
    NSData* resultData = [self intToData:result];
    NSRange range;
    range.location = HEADER_LENGTH;
    range.length = INT_SIZE;
    [entity replaceBytesInRange:range withBytes:[resultData bytes]];
    [self setCmd:CloudCmd_DeleteFileAck];
    [self setLength:[entity length]];
    int crc = [self crcs:entity withLength:[entity length]];
    [self setCrc:crc];
    return self;
}

- (int)getResult{
    int result = -1;
    NSRange range;
    range.location = HEADER_LENGTH;
    range.length = sizeof(result);
    result = [self dataToInt:[entity subdataWithRange:range]];
    return result;
}

@end
